package com.abaaba.project2.controller.wxcontroller;

import com.abaaba.project2.bean.User;
import com.abaaba.project2.bean.bo.WxLoginBo;
import com.abaaba.project2.bean.bo.wx.WXGoodsAndSearchUseBO;
import com.abaaba.project2.bean.vo.BaseRespVo;
import com.abaaba.project2.bean.vo.UserLoginVo;
import com.abaaba.project2.bean.vo.wx.*;
import com.abaaba.project2.service.WxAuthService;
import com.abaaba.project2.service.WxFeedbackService;
import com.abaaba.project2.service.WxFootprintService;
import com.abaaba.project2.service.wx.WXGoodsShowListService;
import com.abaaba.project2.service.wx.WxSearchHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/wx/goods")
public class WXGoodsShowListController {

    @Autowired
    WXGoodsShowListService wxGoodsShowListService;

    /** Issac : 需要新增足迹 */
    @Autowired
    WxFootprintService footprintService;

    @Autowired
    WxSearchHistoryService wxSearchHistoryService;

    @RequestMapping("/list")
    public WXGoodsShowListVO WXGoodsShow(WXGoodsAndSearchUseBO wxGoodsAndSearchUseBO)
    {
        String keyword = wxGoodsAndSearchUseBO.getKeyword();
        wxSearchHistoryService.addHistory(keyword);

        WXGoodsShowListVO wxGoodsShowListVO = wxGoodsShowListService.wxGoodsShowListService(wxGoodsAndSearchUseBO);
        return wxGoodsShowListVO;
    }

    @RequestMapping("/count")
    public BaseRespVo WXGoodsCountList()
    {
        WXIndexGoodsCountVO.DataBean dataBean = wxGoodsShowListService.wxIndexGoodsCount();
        BaseRespVo<WXIndexGoodsCountVO.DataBean> objectBaseRespVo = new BaseRespVo<>();
        objectBaseRespVo.setErrmsg("成功");
        objectBaseRespVo.setData(dataBean);
        objectBaseRespVo.setErrno(0);
        return objectBaseRespVo;
    }

    @RequestMapping("/category")
    public WXGoodsCategoryShowList WXGoodsCategoryList(Integer id)
    {
        WXGoodsCategoryShowList wxGoodsCategoryShowList = wxGoodsShowListService.wxGoodsCategoryShow(id);
        return wxGoodsCategoryShowList;
    }
    @RequestMapping("/related")
    public WXGoodsRealtedShowListVO WXGoodsRelatedList(Integer id)
    {
        WXGoodsRealtedShowListVO wxGoodsRelatedShowListVO = wxGoodsShowListService.wxGoodsRelatedShow(id);
        return wxGoodsRelatedShowListVO;
    }

    @RequestMapping("/detail")
    public WXGoodsDetailShowListVO WXGoodsDetailList(Integer id)
    {
        // Issac : 新增足迹
        footprintService.addFootprint(id);

        WXGoodsDetailShowListVO.DataBeanX dataBeanX = wxGoodsShowListService.wxGoodsDetailList(id);
        WXGoodsDetailShowListVO wxGoodsDetailShowListVO = new WXGoodsDetailShowListVO();
        wxGoodsDetailShowListVO.setData(dataBeanX);
        wxGoodsDetailShowListVO.setErrmsg("成功");
        wxGoodsDetailShowListVO.setErrno(0);
        return wxGoodsDetailShowListVO;
    }


}
